<template>
  <div>
    <el-form
      ref="postForm"
      :model="postForm"
      :rules="rules"
      label-width="200px"
      label-suffix=":"
    >
      <sticky :z-index="10" :class-name="'sub-navbar ' + postForm.status">
        <el-button v-loading="loading" style="margin-left: 10px;" type="success" @click="submitForm">
          保存
        </el-button>
      </sticky>

      <div style="padding: 15px">
        <el-row>
          <el-col :span="22">
            <el-form-item label="金牌代理" style="width: 500px">
              <el-input v-model="postForm.vip1" />
              <span>一次性购买金额</span>
            </el-form-item>
            <el-form-item label="钻石代理" style="width: 500px">
              <el-input v-model="postForm.vip2" />
              <span>一次性购买金额</span>
            </el-form-item>
            <el-form-item label="分公司" style="width: 500px">
              <el-input v-model="postForm.svip1" />
              <span>一次性购买金额</span>
            </el-form-item>
            <el-form-item label="董事1" style="width: 500px">
              <el-input v-model="postForm.svip2" />
              <span>一次性购买金额</span>
            </el-form-item>
            <el-form-item label="董事2" style="width: 500px">
              <el-input v-model="postForm.svip2_svip1" />
              <span>直推多少分公司</span>
            </el-form-item>
            <el-form-item label="董事2" style="width: 500px">
              <el-input v-model="postForm.svip2_team_svip1" />
              <span>团队多少分公司</span>
            </el-form-item>
            <el-divider />
            <!-- vip1 -->
            <el-form-item label="金牌直推金牌" style="width: 500px">
              <el-input v-model="postForm.vip1_vip1_1" />
            </el-form-item>
            <el-form-item label="金牌间推金牌" style="width: 500px">
              <el-input v-model="postForm.vip1_vip1_2" />
            </el-form-item>
            <el-form-item label="金牌直推钻石" style="width: 500px">
              <el-input v-model="postForm.vip1_vip2_1" />
            </el-form-item>
            <el-form-item label="金牌间推钻石" style="width: 500px">
              <el-input v-model="postForm.vip1_vip2_2" />
            </el-form-item>
            <el-form-item label="金牌直推分公司" style="width: 500px">
              <el-input v-model="postForm.vip1_svip1_1" />
            </el-form-item>
            <el-form-item label="金牌间推分公司" style="width: 500px">
              <el-input v-model="postForm.vip1_svip1_2" />
            </el-form-item>
            <!-- vip2 -->
            <el-form-item label="钻石直推金牌" style="width: 500px">
              <el-input v-model="postForm.vip2_vip1_1" />
            </el-form-item>
            <el-form-item label="钻石间推金牌" style="width: 500px">
              <el-input v-model="postForm.vip2_vip1_2" />
            </el-form-item>
            <el-form-item label="钻石直推钻石" style="width: 500px">
              <el-input v-model="postForm.vip2_vip2_1" />
            </el-form-item>
            <el-form-item label="钻石间推钻石" style="width: 500px">
              <el-input v-model="postForm.vip2_vip2_2" />
            </el-form-item>
            <el-form-item label="钻石直推分公司" style="width: 500px">
              <el-input v-model="postForm.vip2_svip1_1" />
            </el-form-item>
            <el-form-item label="钻石间推分公司" style="width: 500px">
              <el-input v-model="postForm.vip2_svip1_2" />
            </el-form-item>
            <!-- svip1 -->
            <el-form-item label="分公司直推金牌" style="width: 500px">
              <el-input v-model="postForm.svip1_vip1_1" />
            </el-form-item>
            <el-form-item label="分公司间推金牌" style="width: 500px">
              <el-input v-model="postForm.svip1_vip1_2" />
            </el-form-item>
            <el-form-item label="分公司直推钻石" style="width: 500px">
              <el-input v-model="postForm.svip1_vip2_1" />
            </el-form-item>
            <el-form-item label="分公司间推钻石" style="width: 500px">
              <el-input v-model="postForm.svip1_vip2_2" />
            </el-form-item>
            <el-form-item label="分公司直推分公司" style="width: 500px">
              <el-input v-model="postForm.svip1_svip1_1" />
            </el-form-item>
            <el-form-item label="分公司间推分公司" style="width: 500px">
              <el-input v-model="postForm.svip1_svip1_2" />
            </el-form-item>
            <!-- svip2 -->
            <el-form-item label="董事直推金牌" style="width: 500px">
              <el-input v-model="postForm.svip2_vip1_1" />
            </el-form-item>
            <el-form-item label="董事间推金牌" style="width: 500px">
              <el-input v-model="postForm.svip2_vip1_2" />
            </el-form-item>
            <el-form-item label="董事直推钻石" style="width: 500px">
              <el-input v-model="postForm.svip2_vip2_1" />
            </el-form-item>
            <el-form-item label="董事间推钻石" style="width: 500px">
              <el-input v-model="postForm.svip2_vip2_2" />
            </el-form-item>
            <el-form-item label="董事直推分公司" style="width: 500px">
              <el-input v-model="postForm.svip2_svip1_1" />
            </el-form-item>
            <el-form-item label="董事间推分公司" style="width: 500px">
              <el-input v-model="postForm.svip2_svip1_2" />
            </el-form-item>
            <el-form-item label="董事直推董事" style="width: 500px">
              <el-input v-model="postForm.svip2_svip2_1" />
            </el-form-item>
            <el-form-item label="董事间推董事" style="width: 500px">
              <el-input v-model="postForm.svip2_svip2_2" />
            </el-form-item>
            <el-divider />
            <el-form-item label="分公司报单奖" style="width: 500px">
              <el-input v-model="postForm.bao_svip1" />
            </el-form-item>
            <el-form-item label="董事报单奖" style="width: 500px">
              <el-input v-model="postForm.bao_svip2" />
            </el-form-item>
            <el-divider />
            <el-form-item label="分公司报单平级奖" style="width: 500px">
              <el-input v-model="postForm.equal_svip1" />
            </el-form-item>
            <el-form-item label="董事报单平级奖" style="width: 500px">
              <el-input v-model="postForm.equal_svip2" />
            </el-form-item>
          </el-col>
        </el-row>
      </div>

    </el-form>
  </div>
</template>

<script>
import Sticky from '@/components/Sticky'
import api from '@/api'
export default {
  name: 'SystemFlow',
  components: {
    Sticky
  },
  data() {
    return {
      postForm: {
        status: 'draft'
      },
      rules: {
      },
      loading: false
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    async fetchData() {
      const { data } = await api.member.fetchSet()
      this.postForm = Object.assign({}, data)
      this.postForm.status = 'publisher'
    },
    submitForm() {
      this.$refs.postForm.validate(validate => {
        if (validate) {
          this.loading = true
          api.member.saveSet({
            ...this.postForm
          }).then(response => {
            this.$notify({
              title: '成功',
              message: response.message || '保存成功',
              type: 'success',
              duration: 2000
            })
            this.loading = false
          }).catch(() => {
            this.loading = false
          })
        }
      })
    }
  }
}
</script>
